#pragma once

#include "Hazel/src/Hazel/Core/Timestep.h"
#include "Hazel/src/Hazel/Render/OrthographicCamera.h"

#include "Hazel/src/Hazel/event/ApplicationEvent.h"
#include "Hazel/src/Hazel/event/MouseEvent.h"

namespace Hazel
{
class OrthographicCameraController
{
  public:
    OrthographicCameraController(float aspactRatio, bool rotation = false); // 2units

    void OnUpdate(Timestep ts);
    void OnEvent(Event &e);

    void OnResize(float width, float height);

    OrthographicCamera &GetCamera()
    {
        return m_Camera;
    }
    const OrthographicCamera &GetCamera() const
    {
        return m_Camera;
    }
    float GetZoomLevel() const
    {
        return m_ZoomLevel;
    }
    void SetZoomLevel(float level)
    {
        m_ZoomLevel = level;
        RecalculateView();
    }

  private:
    void RecalculateView();
    bool OnMouseScrolled(MouseScrolledEvent &e);
    bool OnWindowResized(WindowResizeEvent &e);

  private:
    struct Bounds
    {
        Bounds(float left, float right, float bottom, float top) : Left(left), Right(right), Bottom(bottom), Top(top)
        {
        }
        float Left, Right, Bottom, Top;
    };

  private:
    float m_AspactRatio;
    float m_ZoomLevel = 1.0f;
    Bounds m_Bounds;
    OrthographicCamera m_Camera;
    bool m_Rotation;

    glm::vec3 m_CameraPosition = {0.0f, 0.0f, 0.0f};
    float m_CameraRotation = 0.0f;
    float m_CameraTranslateSpeed = 5.0f, m_CameraRotationSpeed = 180.0f;
};
} // namespace Hazel